// Learn cc.Class:
//  - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/class.html
//  - [English] http://docs.cocos2d-x.org/creator/manual/en/scripting/class.html
// Learn Attribute:
//  - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html
//  - [English] http://docs.cocos2d-x.org/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html
//  - [English] https://www.cocos2d-x.org/docs/creator/manual/en/scripting/life-cycle-callbacks.html

cc.Class({
    extends: cc.Component,

    properties: {
        title: cc.Label,
        text: cc.Label,
    },

    // LIFE-CYCLE CALLBACKS:

    onLoad() {
        if (!this.node.info) {
            this.node.destroy();
        }

        this.text.string = this.node.info.text;
        this.title.string = this.node.info.title;
    },
    onClickOk() {
        cc.utils.msgHub.emit(cc.utils.macro.EVENTS.MSG_BOX_OK, this );
    },
    onClickYes() {
        cc.utils.msgHub.emit(cc.utils.macro.EVENTS.MSG_BOX_YES, this );
    },
    onClickNo() {
        cc.utils.msgHub.emit(cc.utils.macro.EVENTS.MSG_BOX_NO, this );
    }
});
